package mondel;

public class S1_2 implements MondeDao{

	public String encryption(String mes, String key) {
		char ming[]=mes.toCharArray();
		char k[]=key.toCharArray();
		char mi[]=new char[ming.length];
		for(int i=0;i<ming.length;i++)
		{
			mi[i]=(char) (ming[i]+k[i%k.length]-97);
			if(mi[i]>122)
			{
				mi[i]=(char) (mi[i]-26);
			}
		
		}
		return String.valueOf(mi);
	}

	public String deciphering(String mes, String key) {
		char ming[]=mes.toCharArray();
		char k[]=key.toCharArray();
		char mi[]=new char[ming.length];
		for(int i=0;i<ming.length;i++)
		{
			mi[i]=(char) (ming[i]-k[i%k.length]+97);
			if(mi[i]<97)
			{
				mi[i]=(char) (mi[i]+26);
			}
		
		}
		return String.valueOf(mi);
	}

}
